﻿status = -1;
var itemList = Array(
2612077,
2612076,
2613064,
2613065
	);

function start() {
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == 1) {
		status++;
	} else {
		if (mode == 0 && status == 0) {
			im.dispose();
			return;
		}
		status--;
	}
	if (status == 0) {
		var text = "";
		for (var i = 0; i < itemList.length; i++) {
			text += "#L" + i + "##v" + itemList[i] + "##z" + itemList[i] + "##l\r\n";
		}
		im.sendSimple("您可以任意选择一件以下物品请看清楚再选择选错概不负责：\r\n#r" + text);
	} else if (status == 1) {
		var item;
		var itemid = itemList[selection];
		var itemnum = Math.floor(Math.random() * 1 + 1);
		item = im.gainGachaponItem(itemid, itemnum, "V卷轴自选箱", 3);
		if (item != -1) {
			im.gainItem(2435824, -1);
			im.sendOk("恭喜您，获得了" + itemnum + "个#b#z" + itemid + "#");
		} else {
			im.sendOk("请你确认在背包的装备，消耗，其他窗口中是否有一格以上的空间。");
		}
		im.safeDispose();
	}
}
